/** 配合MessageListenerAdapter使用，2种用法：
 * 方法一：
 *  @JmsListener + @SendTo
 * 方法二：
 *  1）在Config中配置@Bean
 *  2）在Config中配置的MessageListenerAdapter Bean中将其注入，messageListenerAdapter.setDelegate
 *  3）在SimpleMessageListenerContainer或DefaultMessageListenerContainer中注入MessageListenerAdapter bean
 *
 *  4）默认使用handleMessage方法，除非在MessageListenerAdapter配置中的DefaultListenerMethod值被另外设定
 *  5）非void返回值意味着将自动给sender发送返回值消息
 */
package com.example.acitvemqspringbootdemo;


import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

import java.util.Map;

//@Component
public class MyAdapterListener {
//    @JmsListener(destination = "send_reply_queue",selector = "listener=3")
//    @SendTo("reply_queue")
    public String  handleMessage(String message) {
        System.out.println("[AdapterListener handleMessage]received TextMessage：" + message);
        return "Reply from MessageListenerAdapter handleMessage";
    }

    public void handleMessage(byte[] message) {
        System.out.println("[AdapterListener handleMessage]received BytesMessage：" + message);
    }
    public void handleMessage(Map<String,Object> message) {
        System.out.println("[AdapterListener handleMessage]received MapMessage：" + message);
    }
    public void handleMessage(Object message) {
        System.out.println("[AdapterListener handleMessage]received ObjectMessage：" + message);
    }


    public String receiveMessage(String message) {
        System.out.println("[AdapterListener receiveMessage]received：" + message);
        return "Reply from MessageListenerAdapter receiveMessage";       //　非void返回值作为返回信息直接发给message.getReplyTo()
    }

}
